from PyQt4 import QtGui
from view.gen import dialog


class TextDialog(QtGui.QDialog):
	def __init__(self, parser_names, parent=None):
		super().__init__(parent)
		self._ui = dialog.Ui_Dialog()
		self._ui.setupUi(self)
		self._ui.cb_parsers.addItems(parser_names)
		self._ui.btnbox.accepted.connect(self.accept)
		self._ui.btnbox.rejected.connect(self.reject)
	
	def exec_(self):
		res = super().exec_()
		if res:
			return self._ui.cb_parsers.currentText(), self._ui.te_text.toPlainText()
		return None
		
